using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using YayiMgr.Ability.Docking.DictionaryApp;
using YayiMgr.Ability.Docking.DictionaryApp.Dto;

namespace YayiMgr.Web
{
    [ApiController]
    [Route("api/[controller]")]
    public class DictionaryItemController : ControllerBase
    {
        public IDictionaryItemServicer DicItemSvr { get; set; }
        // GET: api/<ValuesController>
        [HttpGet()]
        public async Task<List<DictionaryItemDto>> Get()
        {
            return await DicItemSvr.GetAllDictionaryItems();
        }

        // GET api/<ValuesController>/5
        [HttpGet("{id}")]
        public async Task<DictionaryItemDto> Get(Guid id)
        {
            return await DicItemSvr.GetAllDictionaryItemsById(id);
        }

        // POST api/<ValuesController>
        [HttpPost]
        public async Task<DictionaryItemDto> Post(DictionaryItemCreateDto dto)
        {
            return await DicItemSvr.AddDictionaryItem(dto);
        }

        // PUT api/<ValuesController>/5
        [HttpPut("{id}")]
        public async Task Put(Guid id, DictionaryItemUpdateDto value)
        {
            await DicItemSvr.UpdateDictionaryItem(id, value);
        }

        // DELETE api/<ValuesController>/5
        [HttpDelete("{id}")]
        public async Task Delete(Guid id)
        {
            await DicItemSvr.DeleteDictionaryItem(id);
        }        
    }
}